/////////////////////////////////////////////////////////////////////////////
// Name:        network_keeper.h
// Purpose:     
// Author:      syy
// Modified by: 
// Created:     2016-12-21 17:26 
// RCS-ID:      
// Copyright:   
// Licence:     
/////////////////////////////////////////////////////////////////////////////
#ifndef _NETWORK_HEARTBEAT_H_
#define _NETWORK_HEARTBEAT_H_

#include <qbkernel/include/qb_base.h>
#include <core/common_types.h>
#include <core/system/timer_wrapper.h>
#include <core/system/scoped_refptr.h>
#include <core/observer/message_observer.h>

namespace qb
{
	class INetworkHeartBeatNotify
	{
	protected:
		virtual ~INetworkHeartBeatNotify() {}

	public:
		virtual void OnHeartBeat() = 0;
	};

	class CNetworkHeartBeat
	{
	public:
		CNetworkHeartBeat();
		~CNetworkHeartBeat();

	public:
		void Create();
		void Destroy();
		void OnTimer(int32_t nIDTTImer);

		void RegisterNotify(INetworkHeartBeatNotify* pNotify);
		void DeRegisterNotify(INetworkHeartBeatNotify* pNotify);

		void StartNetworkTimer();
		void StopNetworkTimer();

	private:
		void OnNetworkCheckProc();

	private:
		qb::TimerWrapper*					m_pTimerImpl;
		BList<INetworkHeartBeatNotify*>		m_notifys;
		int32_t								m_nIDTNetworkCheck;
	};
}

#endif // _NETWORK_KEEPER_H_
